package com.ctshk.rpc.scenic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.scenic.dto.ScenicProductChannelOnlineSelfPlatformDTO;
import com.ctshk.rpc.scenic.entity.ScenicProductChannelOnlineSelfPlatform;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author xuhui
 * @since 2/2/2021
 */
public interface ScenicProductChannelOnlineSelfPlatformMapper extends BaseMapper<ScenicProductChannelOnlineSelfPlatform> {
    /**
     * 清空门票线上自营自定义权限
     * @param
     * @param
     */
    @Update("UPDATE t_scenic_product_channel_online_self_platform \n" +
            "SET is_deleted = 1 \n" +
            "WHERE product_id = #{product_id}")
    Integer clearByProductId(@Param("product_id") Long productId, @Param("modified_id")Long userId);

    /**
     * 查询线上渠道渠道产品自定义权限
     * @param productId
     * @return
     */
    @Select("select" +
            " product_id productId, channel_id channelId" +
            " from t_scenic_product_channel_online_self_platform where is_deleted = 0 and product_id = #{productId}")
    List<ScenicProductChannelOnlineSelfPlatformDTO> selectChannelTypeListByProductId(@Param("productId") Long productId);

    /**
     * 查询
     * @param productId
     * @return
     */
    @Select("select * from t_scenic_product_channel_online_self_platform where is_deleted = 0 and product_id = #{productId} and channel_id = #{channelId}")
    ScenicProductChannelOnlineSelfPlatformDTO selectByProductId(@Param("productId") Long productId, @Param("channelId") Long channelId);

    /**
     * 查询
     * @param productId
     * @return
     */
    @Select("select * from t_scenic_product_channel_online_self_platform where is_deleted = 0 and product_id = #{productId}")
    List<ScenicProductChannelOnlineSelfPlatformDTO> selectByProductIdList(@Param("productId") Long productId);
}
